package com.uliian.upyundemo.controller;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.uliian.upyundemo.dto.UpyunTokenResult;
import com.uliian.upyundemo.service.UpyunSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.HandlerMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/upyun")
public class UpyunSignController {
    @Autowired
    private UpyunSignService upyunSignService;

    @RequestMapping(value = "/**",method = RequestMethod.GET)
    public UpyunTokenResult getUpyunToken(HttpServletRequest request) throws Exception {
        String path = (String) request.getAttribute(
                HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
        UpyunTokenResult result = upyunSignService.getSign();
        return result;
    }
}
